<?php 
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller{
	function login(){
		
		$this->display();
	}
	function login_check(){
		$userOb=M('User');
		if (empty($_POST['user_name']) || empty($_POST['user_password'])){
            $this->error('账号和密码不能为空！',U('Home/Login/login'));
        }
        $where = [
            'user_name' => $_POST['user_name'],
            'user_password' => $_POST['user_password']
        ];
        $re = $userOb->where($where)->find();
		if ($re) {
			if ($re['user_state']==0) {
					$_SESSION['user_name'] = $_POST['user_name'];
					$this->success('登陆成功',U('Home/Index/index'));
			}else{
				$this->error('账号已被停用',U('Home/Login/login'));
			}
		}else{
			$this->error('密码错误',U('Home/Login/login'));
		}
	}



}